﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3
{
    interface I1 { void Foo(); }
    interface I2 { int Foo(); }


    /// <summary>
    /// 实现多个接口，出现成员签名冲突。
    /// </summary>
    public class Widget : I1, I2
    {
        public void Foo()
        {
            Console.WriteLine("Widget's implementation of I1.Foo");
        }
        int I2.Foo()//显式实现（exlicitly implementing）
        {
            Console.WriteLine("Widget's implementation of I2.Foo");
            return 42;
        }
    }
    class Chapt3_6_2ExplicitInterfaceImplementation
    {

        static void _Main() {            
            Widget w = new Widget();
            w.Foo();        //Widget's implementation of I1.Foo
            ((I1)w).Foo();  //Widget's implementation of I1.Foo
            //调用显式实现成员
            ((I2)w).Foo();  //Widget's implementation of I2.Foo
        }
    }
}
